<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">        
            <ui:define name="content">
                <h:form id="addProductionSchedule" binding="#{productionScheduleManagerBean.loadAddProductionSchedule_psd}">
                    <p:messages id="error"/>
                  
                    <p:panel header="Production information" id="productionSchedule">
                        <table>
                            <tr>
                                <td>Date:</td>
                                 <td><h:outputText value="#{productionScheduleManagerBean.productionSchedule.operationMonth}
                                     / #{productionScheduleManagerBean.productionSchedule.operationYear}" /></td>
                            </tr>
                            <tr>
                                <td>Line number:</td>
                                 <td>Production line <h:outputText value="#{productionScheduleManagerBean.productionSchedule.lineNumber}" /></td>
                            </tr>
                            <tr>
                                <td>Available hours:</td>
                                 <td><h:outputText value="#{productionScheduleManagerBean.productionSchedule.totalNormalUtilizedOperatingHours}
                                     / #{productionScheduleManagerBean.productionSchedule.totalNormalOperatingHours}" /></td>
                            </tr>
                            <tr>
                                <td>Utilization:</td>
                                 <td><h:outputText value="#{productionScheduleManagerBean.productionSchedule.utilizationRate} %" /></td>
                            </tr>
                            
                        </table>

                        <p:dataTable id="productionScheduleDay" var="productionScheduleDay" value="#{productionScheduleManagerBean.productionSchedule.productionScheduleDays}" 
                                     emptyMessage="No production schedule found with given criteria." 
                                     selectionMode ="single" selection="#{productionScheduleManagerBean.selectedProductionScheduleDay}" paginator="true" rows="5"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}">
                            <p:column headerText="Day">  
                                <center> <h:outputText value="#{productionScheduleDay.currentDay}"/> </center>
                            </p:column> 
                            <p:column headerText ="Product">  
                                <center> <h:outputText value="#{productionScheduleDay.product.name}"/> </center>
                            </p:column> 
                            <p:column headerText ="Quantity">  
                                <center> <h:outputText value="#{productionScheduleDay.quantity}"/> </center>
                            </p:column> 
                            <p:column headerText ="Hours taken">  
                                <center> <h:outputText value="#{productionScheduleDay.utilizedHours}"/> </center>
                            </p:column> 
                             <p:column headerText ="Type">  
                                <center> <h:outputText value="#{productionScheduleDay.type}"/> </center>
                            </p:column> 

                        </p:dataTable>
                        <center>  <p:commandButton id="btnRemoveDay" value="Remove" actionListener="#{productionScheduleManagerBean.removeProductionScheduleDay}" ajax="true" update="error" />
                        </center>
                        
                    </p:panel>
                  
                    <p:panel header="Production Schedule Day"  >

                        <table width="100%">


                            <tr>
                                <td> 
                                    Day of Month:
                                </td>         
                                <td> 
                                     <h:selectOneMenu id="day" value="#{productionScheduleManagerBean.productionScheduleDay.currentDay}">
                                       <f:selectItem itemLabel="Select Day" itemValue="0" />
                                        <f:selectItems value="#{productionScheduleManagerBean.days}"/>                                                       
                                    </h:selectOneMenu>                                   
                                    <font class="fieldNote">*</font>
                                    <br/>
                                    <font size="1" color="green">* PH and weekends will not be reflected in the list</font>
                                </td>
                                
                            </tr>
                            <tr>
                                <td> 
                                    Product:
                                </td>
                                <td> 
                                    <h:selectOneMenu id="selectOneProduct" value="#{productionScheduleManagerBean.code}">
                                        <f:selectItem itemLabel="Select Product" itemValue="0" />
                                        <f:selectItems value="#{productionScheduleManagerBean.products}" var="product" 
                                                       itemLabel="#{product.name}" itemValue="#{product.code}"/>
                                    </h:selectOneMenu>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Quantity:
                                </td>
                                <td> 
                                    <p:inputText id ="quantity" value="#{productionScheduleManagerBean.productionScheduleDay.quantity}" >
                                    
                                    </p:inputText>       
                                     <font class="fieldNote">*</font>
                                       <br/>
                                    <font size="1" color="green">* Quantity will automatically adjusted to nearest 0.5 hour</font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    
                                </td>
                                <td>
                                    <p:commandButton id="btnAdd" value="Add" actionListener="#{productionScheduleManagerBean.addProductionScheduleDay}" ajax="true" update="error" />
                                </td>
                            </tr>
                        </table>

                    </p:panel>
                    <br/>
                    <hr></hr>
                    
                    <center><p:commandButton id="btnDone" value="Done" actionListener="#{productionScheduleManagerBean.doneProductionScheduleDay}" ajax="true" update="error" />
                     
                    </center>



                </h:form>
            </ui:define>        
        </ui:composition>
    </body>
</html>
